//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

#ifndef __FINAL_SWITCH_H_
#define __FINAL_SWITCH_H_

#include <omnetpp.h>
#include  <stdio.h>
#include <string.h>
#include <iostream>
#include "Eth_pck_m.h"
#include "FBFrame_m.h"

/**
 * TODO - Generated class
 */
class Switch : public cSimpleModule
{

	typedef struct CP{

		int qlen;
		int qlen_old;
		double time_to_mark;

	}CP;

private:
	int id;
	int sizeofQ;
	int Q_eq;
	int W;
	cChannel *Schannel;
	cQueue waitTosend[5];
	Eth_pck *note;
    CP congP[5];
	cOutVector time_interval_vector;	//timeSpacesVector
	cOutVector que_vector;	//delayVector
	cDoubleHistogram time_interval; //timeSpacesStat
	cDoubleHistogram que;	//delayStat

  protected:
    virtual void initialize();
    virtual void handleMessage(cMessage *msg);
    virtual void CongestionPoint(cMessage *msg);
    virtual double Mark_Table(int qntz_Fb);
    virtual int sixBit(int toQuan);
	virtual void finish();


};

#endif
